<html>
<head><meta charset="utf-8"><title>Difference between `name` and `func_name` · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html">Difference between `name` and `func_name`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189625140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625140">(Mar 03 2020 at 19:24)</a>:</h4>
<p>This is related to the completion function <code>add_function_with_name</code> at <code>crates/ra_ide/src/completion/presentation.rs</code>.</p>
<p>What exactly is the difference between <code>name</code> and <code>func_name</code>?<code>func_name</code> is always present and retrieved from the db, but name is expected to be potentially absent and will use <code>func_name</code> in such case.</p>
<p>Currently there is only flow that passes <code>name</code> as <code>Some</code> - <code>add_resolution</code> but I don't really understand what exactly resolutions are in this context. Is this to support the <code>use X as Y;</code> syntax? ( <code>X</code> is <code>func_name</code> and <code>Y</code> is <code>name</code>?)</p>



<a name="189625501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625501">(Mar 03 2020 at 19:28)</a>:</h4>
<p>it looks like it, though it doesn't seem like it's working fully (<a href="https://github.com/rust-analyzer/rust-analyzer/issues/3356" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/3356">rust-analyzer#3356</a>) <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span></p>



<a name="189625742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625742">(Mar 03 2020 at 19:31)</a>:</h4>
<p>changing the code to always use <code>func_name</code> makes no tests fail <span aria-label="disappointed" class="emoji emoji-1f61e" role="img" title="disappointed">:disappointed:</span></p>



<a name="189625767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625767">(Mar 03 2020 at 19:31)</a>:</h4>
<p>so I guess it was supposed to handle that, but is probably broken</p>



<a name="189625954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625954">(Mar 03 2020 at 19:33)</a>:</h4>
<p><code>name</code> is whatever the name that resolved to the function was, which becomes mostly relevant in the case of <code>use X as Y</code>, yeah</p>



<a name="189625958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189625958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189625958">(Mar 03 2020 at 19:33)</a>:</h4>
<p>I see. Perhaps the name of the variables can be changed to be more clear about their purpose whenever this feature is fixed ;d</p>



<a name="189626129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626129">(Mar 03 2020 at 19:35)</a>:</h4>
<p>and there is no <code>name</code> in the case of method calls, like <code>something.foo()</code> or <code>SomeType::foo()</code> (<code>name</code> will be <code>None</code> and <code>func_name</code> will be <code>"foo"</code>)</p>



<a name="189626277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626277">(Mar 03 2020 at 19:37)</a>:</h4>
<p>yeah but notice that name is re-evaluated if it is <code>None</code>;  <code>let name = name.unwrap_or_else(|| func_name.to_string());</code></p>



<a name="189626292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626292">(Mar 03 2020 at 19:37)</a>:</h4>
<p>yeah, that's why</p>



<a name="189626382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626382">(Mar 03 2020 at 19:38)</a>:</h4>
<p>for method calls, we need the actual declared name, for other calls, we need the name under which the function was actually imported</p>



<a name="189626402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626402">(Mar 03 2020 at 19:38)</a>:</h4>
<p>I think the use of <code>func_name</code> later in the function is wrong and should be <code>name</code> as well</p>



<a name="189626476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626476">(Mar 03 2020 at 19:39)</a>:</h4>
<p>Thanks, I understand.</p>



<a name="189626482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626482">(Mar 03 2020 at 19:39)</a>:</h4>
<p>I think you are right as well</p>



<a name="189626510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626510">(Mar 03 2020 at 19:39)</a>:</h4>
<p>it makes no sense to use the original name when it was imported under a different name</p>



<a name="189626576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626576">(Mar 03 2020 at 19:40)</a>:</h4>
<p>(at least for the snippet itself)</p>



<a name="189626768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626768">(Mar 03 2020 at 19:42)</a>:</h4>
<p>yes. I think I'll just fix it... and I think it actually needs more fixing for other item types</p>



<a name="189626836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626836">(Mar 03 2020 at 19:43)</a>:</h4>
<p>ah no, for other items it works</p>



<a name="189626916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189626916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189626916">(Mar 03 2020 at 19:44)</a>:</h4>
<p>Cool, can you ping me whenever you are done? I am working on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1705" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1705">https://github.com/rust-analyzer/rust-analyzer/issues/1705</a> now and I'm sure we'll conflict</p>



<a name="189627189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189627189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189627189">(Mar 03 2020 at 19:48)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/3430" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/3430">https://github.com/rust-analyzer/rust-analyzer/pull/3430</a></p>



<a name="189627419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189627419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avishay Matayev <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189627419">(Mar 03 2020 at 19:50)</a>:</h4>
<p>That was quick!</p>



<a name="189627548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Difference%20between%20%60name%60%20and%20%60func_name%60/near/189627548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Difference.20between.20.60name.60.20and.20.60func_name.60.html#189627548">(Mar 03 2020 at 19:51)</a>:</h4>
<p>a bit too quick, I forgot to update the snapshot at first ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>